package com.yunduo.controller.front;

import com.yunduo.common.RetunData.CommonReturn;
import com.yunduo.common.RetunData.statuscode.impl.ResultCode;
import com.yunduo.entity.Good;
import com.yunduo.entity.front.SearchGood;
import com.yunduo.service.GoodService;
import com.yunduo.service.GoodTypeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 小程序端搜索显示控制器
 */
@RestController
@RequestMapping("/fsearch")
public class SearchDataController {

    @Resource
    private GoodService goodService;
    @Resource
    private GoodTypeService goodTypeService;
    @PostMapping("/getData")
    public CommonReturn getGoodDatas(@RequestBody @Valid SearchGood query){
        List<Good> list = goodService.selectGoodsForOrderQuery(query.getName(), query.isPrice(), query.isTime(), query.getPage(), 8);
        return CommonReturn.SUCCESS(ResultCode.SUCCESS).setData("list",list);
    }
}
